package View;

import javax.swing.*;
import java.awt.*;
import java.sql.*;

public class After extends JFrame {
    String s;
    JFrame jf=new JFrame("您的评教结果");
    public After(String s){
        Box b=Box.createVerticalBox();
        Box h= Box.createHorizontalBox();
        JLabel j1=new JLabel("面向对象程序设计");
        JLabel j11=new JLabel();
        Box h1= Box.createHorizontalBox();
        JLabel j2=new JLabel("py程序设计            ");
        JLabel j22=new JLabel();
        Box h2= Box.createHorizontalBox();
        JLabel j3=new JLabel("c语言                        ");
        JLabel j33=new JLabel();

        h.add(j1);h.add(Box.createHorizontalStrut(15));h.add(j11);
        h1.add(j2);h1.add(Box.createHorizontalStrut(15));h1.add(j22);
        h2.add(j3);h2.add(Box.createHorizontalStrut(15));h2.add(j33);

        b.add(h);
        b.add(Box.createVerticalStrut(15));
        b.add(h1);
        b.add(Box.createVerticalStrut(15));
        b.add(h2);
        jf.add(b);
        jf.setSize(355,155);
        jf.setLocationRelativeTo(null);
        jf.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        jf.setResizable(false);
        jf.setVisible(true);
        jf.setLayout(new FlowLayout(FlowLayout.CENTER));

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            Connection c= DriverManager.getConnection("jdbc:mysql://localhost:3306/lxt","root","111111");
            Statement s1=c.createStatement();
//                    ResultSet result=s.executeQuery("select *from 注册表 where username='"+zhang+"'");
            ResultSet result1=s1.executeQuery("select *from evaluate where 学号='"+s+"'");
            result1.next();
            String a=result1.getString("面向对象");
            String a1=result1.getString("py程序设计");
            String a2=result1.getString("c语言");
            j11.setText(a);
            j22.setText(a1);
            j33.setText(a2);
            result1.close();
            s1.close();
            c.close();
    } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }


}
}